#ifndef	_LIB_DWINTYPE_H_
#define	_LIB_DWINTYPE_H_


typedef void                dwVOID;
typedef int                 dwINT32;
typedef int                 dwBOOL;
typedef int                 dwSTATUS;
typedef unsigned char       dwU8;
typedef unsigned short      dwU16;
typedef unsigned long       dwU32;
typedef unsigned long long  dwU64;

#define dwTRUE              1
#define dwFALSE             0
#define dwHigh              1
#define dwLow               0
#define dwNULL              (void *)0

#define dwAPI               extern
#define dwExport            extern
	

#define	DW_FRAMEHEAD			0x5AA5U

#define	DW_CMD_WRITEREG			0x80
#define	DW_CMD_READREG			0x81
#define	DW_CMD_WRITEVAR			0x82
#define	DW_CMD_READVAR			0x83

#define	DW_BUFF_MAX		16	//数据缓冲区大小，关系到一次能读取的变量和寄存器数量 1~125
#pragma pack(1)

struct dw_reg_s{
	dwU8	page;
	dwU8	addr;
	dwU8	length;
	dwU8	*value;
};

struct dw_var_s{
	dwU16	addr;
	dwU8	length;
	dwU8	change;
	dwU16	*value;
};


//寄存器帧
struct dw_frame_var_s{
	dwU16	fh;			//帧头
	dwU8	length;		//长度
	dwU8	cmd;
	dwU16	addr;
	dwU8	words;
	dwU16	value[DW_BUFF_MAX];
};

struct dw_frame_var_wr_s{
	dwU16	fh;			//帧头
	dwU8	length;		//长度
	dwU8	cmd;
	dwU16	addr;
	dwU16	value[DW_BUFF_MAX];
};

//寄存器帧
struct dw_frame_reg_s{
	dwU16	fh;			//帧头
	dwU8	length;		//长度
	dwU8	cmd;
	dwU8	page;
	dwU8	addr;
	dwU8	words;
	dwU8	value[DW_BUFF_MAX];
};
#pragma pack()

typedef struct  dw_var_s *				dw_var_t;
typedef struct  dw_reg_s *				dw_reg_t;
typedef struct  dw_frame_var_s *		dw_frame_var_t;
typedef struct  dw_frame_var_wr_s *		dw_frame_var_wr_t;
typedef struct  dw_frame_reg_s *		dw_frame_reg_t;

#define	WR_D16(N)	(dwU16)(N >> 8 | N << 8)
#define	RD_D16(N)	WR_D16(N)
#define	WR_D8(N)	((dwU8)N)
#define	RD_D8(N)	((dwU8)N)




#endif
